@extends('admin.base')


@section('content')
<!-- Content Header (Page header) -->
    <section class="content-header">
          <h1>
            小程序首页管理
            <small>preview of simple tables</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">小程序首页管理</a></li>
            <li class="active">小程序首页管理</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-md-12">
              <div class="box">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-th"></i> 小程序首页管理</h3>
                  &nbsp; <button class="btn btn-sm btn-primary" onclick="window.location='{{URL('class/create')}}'">发布类别</button>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table class="table table-bordered" style='table-layout:fixed;'>
                    <tr>
                      <th style="width:60px">###号</th>
                      <th>类别名称</th>
                  <th>类别图片</th>
              
                      <th>添加时间</th>

                      <th style="width: 170px">操作</th>
                    </tr>
              @foreach($list as $vo)
                        <tr>
                            <td>{{$vo->id}}</td>
                            <th>{{$vo->type_name}}</th>
                            <td><img style="width:30px;" src="uploads/{{$vo->type_img}}"></td>
                            <td>{{$vo->created_at}}</td>
                        
                            <td>
                              
                                <button onclick="doDel()" class="btn btn-xs btn-danger">删除</button> 
                                
                                <button class="btn btn-xs btn-primary" onclick="window.location='{{URL('product')}}'">编辑</button>
                                
                            </td>
                        </tr>
                @endforeach
                    
                  </table>
                </div><!-- /.box-body -->
                <div class="box-footer clearfix">
                 
                </div>
              </div><!-- /.box -->

            </div><!-- /.col --> 
          </div><!-- /.row -->
        </section><!-- /.content -->
        
    @endsection
    
    @section('myscript')
    <form action="/users/" method="post" name="myform" style="display:none;">
            <input type="hidden" name="_token" value="{{ csrf_token() }}"/>
            <input type="hidden" name="_method" value="delete"/>
           
    </form>
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">New message</h4>
          </div>
          <div class="modal-body">
           <!-- 此处填充 -->
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" onclick="saveRole()" class="btn btn-primary">保存</button>
          </div>
        </div>
      </div>
    </div>
    <script type="text/javascript">
        function doDel(id){
            Modal.confirm({msg: "是否删除信息？"}).on(function(e){
                if(e){
                   var form = document.myform;
                    form.action = "{{URL('product')}}/"+id;
                    form.submit(); 
                }
              });
        }
        
        
        
        function true_Top(id){
            Modal.confirm({msg:'是否确定推荐？'}).on(function (e){
                if(e){
                   $.ajax({
                     headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                      },
                      url:'{{url("true_top")}}',
                      data:{
                        id:id,
                      },
                      success:function(res){
                          alert('推荐成功');
                      }
                      
                   });
                }
            });
        }
        
       function false_Top(id){
           Modal.confirm({msg:'是否确定取消推荐？'}).on(function (e){
                if(e){
                   $.ajax({
                     headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                      },
                      url:'{{url("false_top")}}',
                      data:{
                        id:id,
                      },
                      success:function(res){
                          alert('取消推荐成功');
                      }
                      
                   });
                }
            });
       }
       
            
            
            
       
    </script>
    @endsection